/**
 * Created by kaider on 2016/12/3.
 * 主要用于获取柱状图和饼状图
 */
//柱状图
function getBarOption(val1,val2,val3,val4,val5,val6,val7,val8) {
    return {
        tooltip: {},
        xAxis: {
            data: ["现金","一元硬币","微信","支付宝","游戏币","出币","出礼品","远程补币"]
        },
        yAxis: {},
        series: [{
            type: 'bar',
            barWidth:50,
            itemStyle: {
                normal: {
                    label: {
                        show: true,
                        textStyle: {color: '#999'},
                        position: 'top'
                    },
                },
            },
            data: [
                {value:val1,itemStyle:{normal:{color:'#ffc600'}}},
                {value:val2,itemStyle:{normal:{color:'#ff8a00'}}},
                {value:val3,itemStyle:{normal:{color:'#11cd6e'}}},
                {value:val4,itemStyle:{normal:{color:'#56abe4'}}},
                {value:val5,itemStyle:{normal:{color:'#ffa200'}}},
                {value:val6,itemStyle:{normal:{color:'#7eff00'}}},
                {value:val7,itemStyle:{normal:{color:'#ff4e00'}}},
                {value:val8,itemStyle:{normal:{color:'#0060ff'}}}
            ]
        }]
    };
}
//饼状图
function getPieOption(val1,val2,val3,val4) {
    return {
        color: ['#ffc600','#ff8a00', '#11cd6e', '#56abe4'],
        tooltip: {
            axisPointer: {
                type: 'none'
            }
        },
        legend: {
            orient: 'vertical',
            x: '2%',
            top: '10%',
            data:['现金','一元硬币','微信','支付宝']
        },
        series: [
            {
                type:'pie',
                radius: ['30%', '70%'],
                avoidLabelOverlap: false,
                itemStyle: {
                    normal: {
                        label: {show:false},
                        labelLine: {show:false},
                        shadowColor: 'rgba(40, 40, 40,0.5)',
                    }
                },
                label: {
                    normal: {
                        show: false,
                        position: 'center'
                    },
                    emphasis: {
                        show: true,
                        formatter: function (param) {
                            return param.percent.toFixed(0) + '%';
                        },
                        textStyle: {
                            fontSize: '30',
                            fontWeight: 'bold'
                        }
                    }
                },
                labelLine: {
                    normal: {
                        show: true
                    }
                },
                data:[
                    {value:val1, name:'现金'},
                    {value:val2, name:'一元硬币'},
                    {value:val3, name:'微信'},
                    {value:val4, name:'支付宝'}
                ]
            }
        ]
    };
}

//折线图
function getLineOption(dayVal,dataVal) {
    return {
        color:['#38adff'],
        tooltip: {
            trigger: 'axis',
            axisPointer: {
                type: 'none'
            }
        },
        toolbox: {
            show: true,
            feature: {
                dataZoom: {
                    yAxisIndex: 'none'
                },
                dataView: {readOnly: false},
                magicType: {type: ['line', 'bar']},
                restore: {},
                saveAsImage: {}
            }
        },
        xAxis:  {
            type: 'category',
            boundaryGap: true,
            data: dayVal
        },
        yAxis: {
            type: 'value',
            axisLabel: {
                formatter: '{value}'
            }
        },
        series: [
            {
                name:'收入',
                type:'line',
                symbol: 'circle',
                symbolSize: 12,
                data:dataVal,
                label: {
                    normal: {
                        show: true,
                        position: 'top'
                    }
                },
                markLine: {
                    data: [
                        {type: 'average', name: '平均值'},
                        [{
                            symbol: 'none',
                            x: '90%',
                            yAxis: 'max'
                        }, {
                            symbol: 'circle',
                            symbolSize: 12,
                            label: {
                                normal: {
                                    show: true,
                                    position: 'top'
                                }
                            },
                            type: 'max',
                            name: '最大值'
                        }]
                    ]
                }
            }
        ]
    };
}

//堆叠条形图
function getStackBarOption(dayVal, dataVal1, dataVal2, dataVal3) {
    return {
        "tooltip": {
            "trigger": "axis",
            "axisPointer": {
                "type": "none",
            },
        },
        "grid": {
            "borderWidth": 0,
            "top": 70,
            "bottom": 40,

        },
        "legend": {
            x: '70%',
            top: '10%',
            textStyle: {
                color: '#000',
            },
            data:['合计','微信', '支付宝']
        },

        "calculable": true,
        "xAxis": [{
            "type": "category",
            "axisLine": {
                lineStyle: {
                    color: '#000'
                }
            },
            "data": dayVal
        }],
        "yAxis": [{
            "type": "value",
            "splitLine": {
                "show": false
            },
            "axisLine": {
                lineStyle: {
                    color: '#000'
                }
            }

        }],

        "series": [{
            "name": "微信",
            "type": "bar",
            "stack": "收入",
            "barMaxWidth": 50,
            "barGap": "10%",
            "itemStyle": {
                "normal": {
                    "color": '#11cd6e',
                    "label": {
                        "show": true,
                        "textStyle": {
                            "color": "#fff"
                        },
                        "position": "insideTop",
                        formatter: function(p) {
                            return p.value > 0 ? (p.value) : '';
                        }
                    }
                }
            },
            "data": dataVal1,
        },
            {
                "name": "支付宝",
                "type": "bar",
                "stack": "收入",
                "itemStyle": {
                    "normal": {
                        "color": '#56abe4',
                        "barBorderRadius": 0,
                        "label": {
                            "show": true,
                            "position": "insideTop",
                            formatter: function(p) {
                                return p.value > 0 ? (p.value) : '';
                            }
                        }
                    }
                },
                "data": dataVal2
            }, {
                "name": "合计",
                "type": "line",
                "stack": "收入",
                symbolSize:10,
                symbol:'circle',
                "itemStyle": {
                    "normal": {
                        "color": "#ff8a00",
                        "barBorderRadius": 0,
                        "label": {
                            "show": true,
                            "position": "top",
                            formatter: function(p) {
                                return p.value > 0 ? (p.value) : '';
                            }
                        }
                    }
                },
                "data": dataVal3
            }
        ]
    };
}